﻿@model ScmCostledgerViewModel
@{
    Layout = null;
    ViewBag.Title = "奖励/罚款台帐-列表";
    string str = "";
}
<script type="text/javascript">
    $(document).ready(function () {
        $(".combox").val("@ViewBag.numPerPage");
    });
</script>
    <div class="panelBar">
        <ul class="toolBar">
            <li><a id="CostLedgerExportId@(ViewBag.Type)" class="export" href="javascript:void();" targettype="navTab"
   title="您确定要导出这些记录吗?"><span>导出</span></a></li>
            <input id="ViewBagtype@(ViewBag.Type)" type="hidden" value="@(ViewBag.Type)" />
        </ul>
    </div>
    <table id="targetTableExport@(ViewBag.Type)" width="100%" layouth="49" class="list">
    <thead>
        <tr>
            <th width="5%" align="center" valign="middle">
                年份
            </th>
            @for (int i = 1; i < Model.dthead.Columns.Count; i++)
            {
                <th width="5%" align="center" valign="middle">
                    @Model.dthead.Columns[i].ColumnName
            </th>
            }
        </tr>
    </thead>
    <tbody>
        @for (int i = 0; i < Model.dthead.Rows.Count; i++)
        {
            <tr>
                @for (int j = 0; j < Model.dthead.Columns.Count; j++)
                {
                    <td style="text-align: center">
                        @Model.dthead.Rows[i][j].ToString()
                </td>
                }
            </tr>
        }
        @for (int i = 0; i < Model.dt.Rows.Count; i++)
        {
            if (Convert.ToDateTime(@Model.dt.Rows[i][0].ToString()).Day != 1)
            {
                str = "style=color:red";
            }
            else
            {
                str = "";
            }
            <tr @str>
                @for (int j = 0; j < Model.dt.Columns.Count; j++)
                {
                    if (j == 0)
                    {
                        if (Convert.ToDateTime(@Model.dt.Rows[i][j].ToString()).Day != 1)
                        {
                            <td style="text-align: center;">
                                @Convert.ToDateTime(@Model.dt.Rows[i][j].ToString()).Year.ToString()年合计
                        </td>

                        }
                        else
                        {
                            <td style="text-align: center">
                                @Convert.ToDateTime(@Model.dt.Rows[i][j]).ToString("yyyy年M月")
                        </td>

                        }

                    }
                    else
                    {
                        <td style="text-align: center">
                            @Model.dt.Rows[i][j].ToString()
                    </td>
                    }

                }
            </tr>
        }
        @for (int i = 0; i < Model.dtend.Rows.Count; i++)
        {
            <tr style="color: red; font-weight: bold">
                @for (int j = 0; j < Model.dtend.Columns.Count; j++)
                {

                    <td style="text-align: center;">
                        @Model.dtend.Rows[i][j].ToString()
                </td>
                }
            </tr>
        }
    </tbody>
</table>

<script src="../../Areas/SafetyConstruction/Scripts/unis.ylx.app.js"></script>
<script>
    $(document).ready(function () {
        $("#CostLedgerExportId@(ViewBag.Type)").bind("click", function () {

            var table = "<table>" + $("#targetTableExport@(ViewBag.Type)")[0].innerHTML + "</table>";
            var enCodeTable = encodeURI(table);
            $.ajax(
           {
               url: "/SafetyConstruction/ScmCostLedger/ExportExcelTest",
               data: { tableHtml: enCodeTable, type: $("#ViewBagtype@(ViewBag.Type)").val() },
               success: function (res) {
                   window.open(JSON.parse(res).src);
               },
               error: function (res) {

               },
               async: false,
               type: "post"
           });


            //ajaxOpt.AjaxDoActionWidthData("ScmCostActual/ExportExcelTest", table, function (scuess) {

            //}, function (error) {

            //});
        });

    });
</script>
